home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Deutsche Edition 1
/
Deutsche Edition 1.iso
/
amok
/
amok_lha
/
amok29.lha
/
CreateIcons
/
SecureDos.imp
< prev
next >
Wrap
Text File
|
1993-08-15
|
2KB
|
99 lines
IMPLEMENTATION SecureDos;
IMPORT d: Dos,
l: Lists;
TYPE
FHListPtr = POINTER TO FHList;
FHList = RECORD (l.Node) fh: d.FileHandlePtr END;
LockListPtr = POINTER TO LockList;
LockList = RECORD (l.Node) lock: d.FileLockPtr END;
VAR
fhlist: FHListPtr;
locklist: LockListPtr;
PROCEDURE Open(name: LONGINT;
accessMode: LONGINT): d.FileHandlePtr;
VAR
el: FHListPtr;
BEGIN
NEW(el);
IF el=NIL THEN RETURN NIL END;
el.fh := d.Open(name,accessMode);
IF el.fh=NIL THEN DISPOSE(el); RETURN NIL END;
l.Add(fhlist,el^);
RETURN el.fh;
END Open;
PROCEDURE Close(file: d.FileHandlePtr);
VAR el: FHListPtr;
BEGIN
el := fhlist;
LOOP
IF el.fh=file THEN
d.Close(file);
l.Rem(fhlist,el^);
DISPOSE(el);
RETURN;
END;
IF el.next=NIL THEN EXIT END;
el := el.next(FHListPtr);
END;
HALT(20); (* File gar nicht offen! *)
END Close;
PROCEDURE Lock(name: LONGINT;
accessMode: LONGINT): d.FileLockPtr;
VAR el: LockListPtr;
BEGIN
NEW(el);
IF el=NIL THEN RETURN NIL END;
el.lock := d.Lock(name,accessMode);
IF el.lock=NIL THEN DISPOSE(el); RETURN NIL END;
l.Add(locklist,el^);
RETURN el.lock;
END Lock;
PROCEDURE UnLock(lock: d.FileLockPtr);
VAR el: LockListPtr;
BEGIN
el := locklist;
LOOP
IF el.lock=lock THEN
d.UnLock(lock);
l.Rem(locklist,el^);
DISPOSE(el);
RETURN;
END;
IF el.next=NIL THEN EXIT END;
el := el.next(LockListPtr);
END;
HALT(20); (* existiert nicht ! *)
END UnLock;
BEGIN
fhlist := NIL;
locklist := NIL;
CLOSE
WHILE fhlist#NIL DO Close(fhlist.fh) END;
WHILE locklist#NIL DO UnLock(locklist.lock) END;
END SecureDos.